package com.parking.common.core.paracheck.checker;

import com.parking.common.core.paracheck.JpgOrPng;
import com.parking.common.core.paracheck.JustTwoDecimal;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 自定义注释 字符串图片格式检测器
 * */
public class JpgOrPngChecker implements ConstraintValidator<JpgOrPng, String> {
    /**
     * 字符串图片格式校验方法
     * */
    @Override
    public boolean isValid(String picturePath, ConstraintValidatorContext constraintValidatorContext) {
        if(picturePath==null||picturePath.equals("")) return true;
        if(picturePath.endsWith(".jpg")) return true;
        if(picturePath.endsWith(".png")) return true;
        return false;
    }
}
